<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Introduction - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.measure.introduction.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.measure.introduction.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.measure.html">Zend_Measure</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.measure.html">Zend_Measure</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.measure.creation.html">Creation of Measurements</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.measure.introduction" class="section"><div class="info"><h1 class="title">Introduction</h1></div>

    

    <p class="para">
        <span class="classname">Zend_Measure_*</span> classes provide a generic and easy way for working
        with measurements. Using <span class="classname">Zend_Measure_*</span> classes, you can convert
        measurements into different units of the same type. They can be added, subtracted and
        compared against each other. From a given input made in the user&#039;s native language, the unit
        of measurement can be automatically extracted. Numerous units of measurement are supported.
    </p>

    <div class="example" id="zend.measure.introduction.example-1"><div class="info"><p><b>Example #1 Converting measurements</b></p></div>
        

        <div class="example-contents"><p>
            The following introductory example shows automatic conversion of units of measurement.
            To convert a measurement, its value and its type have to be known. The value can be an
            integer, a float, or even a string containing a number. Conversions are only possible
            for units of the same type (mass, area, temperature, velocity, etc.), not between types.
        </p></div>

        <pre class="programlisting brush: php">
$locale = new Zend_Locale(&#039;en&#039;);
$unit = new Zend_Measure_Length(100, Zend_Measure_Length::METER, $locale);

// Convert meters to yards
echo $unit-&gt;convertTo(Zend_Measure_Length::YARD);
</pre>

    </div>

    <p class="para">
        <span class="classname">Zend_Measure_*</span> includes support for many different units of
        measurement. The units of measurement all have a unified notation:
        <span class="classname">Zend_Measure_&lt;TYPE&gt;::NAME_OF_UNIT</span>, where &lt;TYPE&gt;
        corresponds to a well-known physical or numerical property. . Every unit of measurement
        consists of a conversion factor and a display unit. A detailed list can be found in the
        chapter <a href="zend.measure.types.html" class="link">Types of measurements</a>.
    </p>

    <div class="example" id="zend.measure.introduction.example-2"><div class="info"><p><b>Example #2 The meter measurement</b></p></div>
        

        <div class="example-contents"><p>
            The <em class="emphasis">meter</em> is used for measuring lengths, so its type constant can
            be found in the <span class="classname">Length</span> class. To refer to this unit of
            measurement, the notation <b><tt>Length::METER</tt></b> must be used. The display
            unit is <em class="emphasis">m</em>.
        </p></div>

        <pre class="programlisting brush: php">
echo Zend_Measure_Length::STANDARD;  // outputs &#039;Length::METER&#039;
echo Zend_Measure_Length::KILOMETER; // outputs &#039;Length::KILOMETER&#039;

$unit = new Zend_Measure_Length(100,&#039;METER&#039;);
echo $unit;
// outputs &#039;100 m&#039;
</pre>

    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.measure.html">Zend_Measure</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.measure.html">Zend_Measure</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.measure.creation.html">Creation of Measurements</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="reference.html">Refer&ecirc;ncia do Zend Framework</a></li>
  <li class="header up"><a href="zend.measure.html">Zend_Measure</a></li>
  <li class="active"><a href="zend.measure.introduction.html">Introduction</a></li>
  <li><a href="zend.measure.creation.html">Creation of Measurements</a></li>
  <li><a href="zend.measure.output.html">Outputting measurements</a></li>
  <li><a href="zend.measure.edit.html">Manipulating Measurements</a></li>
  <li><a href="zend.measure.types.html">Types of measurements</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>